home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / alangsbs.zip / VIDCHECK.SRC < prev    next >
Text File  |  1989-12-12  |  5KB  |  82 lines

  1. ;---------------------------------------------------------------
  2. ;   VidCheck  --  Identifies display board & display parameters
  3. ;   Last update 3/16/89
  4. ;
  5. ;   1 entry point:
  6. ;
  7. ;   VidCheck:
  8. ;      Caller need pass no parameters.
  9. ;      VidCheck identifies the installed display board by
  10. ;      calling DispID.  It then calculates numerous display
  11. ;      information values, which it then stores in the block
  12. ;      of display information variables in the data segment.
  13. ;---------------------------------------------------------------
  14.  
  15. VidCheck   PROC
  16.            ; First task is to figure out which board is on the bus:
  17.            call DispID        ; Ask BIOS for adapter code; returns in AL
  18.            mov  DispType,AL   ; Store display adapter code in DispType
  19.  
  20.            ; Next we determine the font size currently in force:
  21.            cmp  AL,0AH        ; See if board is an MCGA
  22.            jl   TryOld        ; If less than code 0AH, it's not an MCGA
  23.            mov  FontSize,16   ; MCGA supports *only* 16 pixel text font
  24.            jmp  GetName       ; Jump ahead to look up adapter name string
  25. TryOld:    cmp  DispType,1    ; Is the display adapter code 1, for MDA?
  26.            jne  TryCGA        ; If not, go test for CGA code 2
  27.            mov  FontSize,14   ; MDA uses *only* 14-pixel text font
  28.            jmp  GetName       ; Jump ahead to look up adapter name string
  29. TryCGA:    cmp  DispType,2    ; Is the display adapter code 2, for CGA?
  30.            jne  TryVGA        ; If not, go test for EGA/VGA font size
  31.            mov  FontSize,8    ; CGA uses *only* 8-pixel text font
  32.            jmp  GetName       ; Jump ahead to look up adapter name string
  33. TryVGA:    mov  AH,11H        ; Select VIDEO Get Font Information subservice
  34.            mov  AL,30H        ;   requires AH = 11H and AL = 30H
  35.            mov  BH,0          ; 0 = Get info about current font
  36.            int  10H           ; Call VIDEO
  37.            mov  FontSize,CL   ; Font size in pixels is returned in CL
  38.  
  39.            ; Next we get the name string for the board from the info table:
  40. GetName:   mov  AL,DispType   ; Load display adapter code into AL
  41.            xor  AH,AH         ; Zero AH so we don't copy trash into DI
  42.            mov  DI,AX         ; Copy AX (with code in AL) into DI
  43.            mov  CL,5          ; We must shift the code 5 bits to mult. by 32
  44.            shl  DI,CL         ; Multiply code by 32 to act as table index
  45.            lea  BX,VidInfoTbl ; Load address of info. table into BX
  46.            mov  BordName,BX   ; Save pointer to video info. table in BordName
  47.            add  Bordname,DI   ; Add offset into table to right element
  48.  
  49.            ; Next we get the refresh buffer segment from the table:
  50.            mov  AX,[BX+DI+27] ; Index into table past name string to segment
  51.            mov  VidSegment,AX ; Store segment from table to VidSegment variable
  52.  
  53.            ; Here we calculate the number of lines on-screen from font size:
  54.            xor  AH,AH         ; Make sure AH has no trash in it
  55.            mov  AL,FontSize   ; Load the font size in pixels into AL
  56.            cmp  AL,8          ; Is it the 8-pixel font?
  57.            jne  Try14         ; If not, try the 14-pixel font
  58.            mov  AL,1          ; The 8-pixel font is table offset 1
  59.            jmp  ReadLns       ; Jump ahead to read screen lines from table
  60. Try14:     cmp  AL,14         ; Is it the 14-pixel font?
  61.            jne  Do16          ; If not, it has to be the 16-pixel font
  62.            mov  AL,2          ; The 14-pixel font is table offset 2
  63.            jmp  ReadLns       ; Jump ahead to read screen lines from table
  64. Do16:      mov  AL,3          ; The 16-pixel font is table offset 3
  65. ReadLns:   add  DI,AX         ; Add font size offset to table element offset
  66.            mov  AL,[BX+DI+28] ; Load the screen lines value from the table
  67.            mov  VisibleY,AL   ;  and store it in the VisibleY variable
  68.            mov  AH,VisibleX   ; Load the screen columns value to AH
  69.            xchg AH,AL         ; Exchange AH & AL for 0-basing
  70.            dec  AL            ; Subtract one from column count for 0-basing
  71.            dec  AH            ; Subtract one from line count for zero-basing
  72.            mov  LRXY,AX       ; And store 0-based X,Y word into LRXY variable
  73.  
  74.            ; Finally, we calculate the size of the refresh buffer in bytes:
  75.            mov  AL,VisibleY   ; We multiply screen lines time screen columns
  76.            mul  VisibleX      ;  times 2 (for attributes) to get buffer size
  77.            shl  AX,1          ; Multiply lines * columns by 2
  78.            mov  VidBufSize,AX ; Store refresh buffer size in VidBufSize
  79.  
  80.            ret                ; Return to caller
  81. VidCheck   ENDP
  82.